<script setup>
import { RouterLink, RouterView } from 'vue-router'
import { ref, onMounted } from 'vue'

const isMobile = ref(false)

onMounted(() => {
  const checkMobile = () => {
    isMobile.value = window.innerWidth <= 768
  }
  
  checkMobile()
  window.addEventListener('resize', checkMobile)
})
</script>

<template>
  <div id="app">
    <header>
      <div class="game-header">
        <h1 class="game-title">🎨 涂色抢地盘游戏</h1>
        <nav>
          <RouterLink to="/">🏠 首页</RouterLink>
          <RouterLink to="/lobby">🎮 游戏大厅</RouterLink>
          <RouterLink to="/about">ℹ️ 关于</RouterLink>
        </nav>
      </div>
    </header>

    <main>
      <RouterView />
    </main>

    <footer v-if="isMobile" class="mobile-footer">
      <div class="footer-nav">
        <RouterLink to="/" class="footer-link">
          <span class="icon">🏠</span>
          <span class="text">首页</span>
        </RouterLink>
        <RouterLink to="/lobby" class="footer-link">
          <span class="icon">🎮</span>
          <span class="text">大厅</span>
        </RouterLink>
        <RouterLink to="/about" class="footer-link">
          <span class="icon">ℹ️</span>
          <span class="text">关于</span>
        </RouterLink>
      </div>
    </footer>
  </div>
</template>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  margin: 0 !important;
  padding: 0 !important;
}

html {
  overflow: hidden;
  height: 100vh;
  margin: 0 !important;
  padding: 0 !important;
  width: 100vw;
}

#app {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 100vw !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

header {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  width: 100vw !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

.game-header {
  width: 100% !important;
  max-width: 100% !important;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  padding: 1rem 2rem;
  margin: 0 !important;
  box-sizing: border-box;
  border: none;
}

.game-title {
  font-size: 2rem;
  font-weight: bold;
  color: white;
  margin: 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

nav {
  display: flex;
  gap: 1rem;
}

nav a {
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  transition: all 0.3s ease;
  font-weight: 500;
}

nav a:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

nav a.router-link-active {
  background-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

main {
  flex: 1;
  max-width: 100%;
  margin: 0;
  padding: 80px 0 0 0; /* 添加顶部padding，确保内容不被导航栏遮挡 */
  width: 100%;
  min-height: 0;
  box-sizing: border-box;
}

.mobile-footer {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.5rem 0;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: none;
}

.footer-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.footer-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: white;
  text-decoration: none;
  padding: 0.5rem;
  transition: all 0.3s ease;
}

.footer-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
}

.footer-link.router-link-active {
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 0.5rem;
}

.footer-link .icon {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.footer-link .text {
  font-size: 0.75rem;
}

@media (max-width: 768px) {
  .game-header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    padding: 1rem 0;
  }
  
  .game-title {
    font-size: 1.5rem;
  }
  
  nav {
    display: none;
  }
  
  main {
    padding: 0;
    margin-bottom: 60px;
  }
  
  .mobile-footer {
    display: block;
  }
}

@media (max-width: 480px) {
  .game-title {
    font-size: 1.25rem;
  }
  
  .footer-link .text {
    font-size: 0.625rem;
  }
}
</style>
